
.PHONY: all clean base concrete

#### Parameter Vars ####
ifndef OS
 OS 		:= linux
endif

ifndef PLAYER
 PLAYER		:= ffmpeg
endif

#### Include OS dirs
ifeq ($(OS), linux)
 OS_PATH	:= $(PWD)/code/concrete/os/linux
else
 ifeq ($(OS), macosx)
  OS_PATH	:= $(PWD)/code/concrete/os/macosx
 endif
endif
 
#### Include OS dirs
PLAYER_PATH	:= players/$(PLAYER)

#### Global Vars definition area ####
CPP_FLAGS 	:= -D$(PLAYER)
LD_FLAGS	:= -lboost_thread
#W_FLAGS 	:= -Wall -g -c
W_FLAGS 	:= -g -c
CC 		:= g++
PWD 		:= $(shell pwd)
RM 		:= rm
BUILD_DIR	:= $(PWD)/build
EXEC		:= ncl.bin		

ifeq ($(EXT), y)
 INC_PATH	:= -Iexternal/lib/boost_1_46_0 
 LIB_PATH	:= -Lexternal/lib/boost_1_46_0/stage/lib
 CPP_FLAGS	+= $(INC_PATH) 
endif


ifeq ($(OS), linux)
 ifeq ($(PLAYER), vlc)
  LD_FLAGS	+= -lvlc
 endif
endif

#### Include OS dirs area to compile each module separately ####
-include $(PWD)/code/concrete/concrete.mk
-include $(PWD)/code/base/base.mk

#### Global targets ####
all: clean concrete base 
	@echo "=> Building OpenNcl executable..."
	$(CC) $(W_FLAGS) $(CPP_FLAGS) -o $(BUILD_DIR)/main.o code/main.cpp
	$(CC) -o $(EXEC) $(CONC_OBJ_FILES) $(BASE_OBJ_FILES) $(BUILD_DIR)/main.o $(LD_FLAGS) $(LIB_PATH)


clean: cbase cconcrete
	$(RM) -f $(BUILD_DIR)/*.o
dep: basedep concretedep 485libdep

help:
	@echo "**************************************************"
	@echo "* to Building exe:               	     	*"
	@echo "* On Linux:      :               	     	*"
	@echo "* make all OS=linux PLAYER=ffmpeg 		*"
	@echo "* make all OS=linux PLAYER=vlc  	     	*"
	@echo "*                              	     		*"
	@echo "* On MacOsX      :               	     	*"
	@echo "* make all OS=macosx PLAYER=vlc EXT=y 		*"
	@echo "*************************************************"
